USE [master]
ALTER DATABASE [Mentoring2014] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

/****** Object:  Database [Mentoring2014]    Script Date: 26.06.2014 20:51:53 ******/
DROP DATABASE [Mentoring2014]
GO

/****** Object:  Database [Mentoring2014]    Script Date: 26.06.2014 20:51:53 ******/
CREATE DATABASE [Mentoring2014]
 CONTAINMENT = NONE
 ON  PRIMARY 
( NAME = N'Mentoring2014', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\Mentoring2014.mdf' , SIZE = 5120KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'Mentoring2014_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\Mentoring2014_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO

ALTER DATABASE [Mentoring2014] SET COMPATIBILITY_LEVEL = 110
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [Mentoring2014].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [Mentoring2014] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [Mentoring2014] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [Mentoring2014] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [Mentoring2014] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [Mentoring2014] SET ARITHABORT OFF 
GO

ALTER DATABASE [Mentoring2014] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [Mentoring2014] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [Mentoring2014] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [Mentoring2014] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [Mentoring2014] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [Mentoring2014] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [Mentoring2014] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [Mentoring2014] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [Mentoring2014] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [Mentoring2014] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [Mentoring2014] SET  DISABLE_BROKER 
GO

ALTER DATABASE [Mentoring2014] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [Mentoring2014] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [Mentoring2014] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [Mentoring2014] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [Mentoring2014] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [Mentoring2014] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [Mentoring2014] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [Mentoring2014] SET RECOVERY FULL 
GO

ALTER DATABASE [Mentoring2014] SET  MULTI_USER 
GO

ALTER DATABASE [Mentoring2014] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [Mentoring2014] SET DB_CHAINING OFF 
GO

ALTER DATABASE [Mentoring2014] SET FILESTREAM( NON_TRANSACTED_ACCESS = OFF ) 
GO

ALTER DATABASE [Mentoring2014] SET TARGET_RECOVERY_TIME = 0 SECONDS 
GO

ALTER DATABASE [Mentoring2014] SET  READ_WRITE 
GO

--------------------------------------------------------------------------------
--Create tables
USE [Mentoring2014]
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO


/****** Object:  Table [dbo].[Person]    Script Date: 26.06.2014 21:03:28 ******/
CREATE TABLE [dbo].[Person](
	[ID] [uniqueidentifier] NOT NULL,
	[NAME] [nvarchar](100) NOT NULL,
	[BIRTH_DATE] [date] NOT NULL,
 CONSTRAINT [PK_Person] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


/****** Object:  Table [dbo].[Reward]    Script Date: 26.06.2014 21:04:03 ******/
SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Reward](
	[ID] [uniqueidentifier] NOT NULL,
	[TITLE] [nvarchar](100) NOT NULL,
	[DESCRIPTION] [nvarchar](max) NOT NULL,
	[IMAGE] [uniqueidentifier] NULL,
 CONSTRAINT [PK_Reward] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


/****** Object:  Table [dbo].[PersonReward]    Script Date: 26.06.2014 21:03:42 ******/
CREATE TABLE [dbo].[PersonReward](
	[PERSON_ID] [uniqueidentifier] NOT NULL,
	[REWARD_ID] [uniqueidentifier] NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[PersonReward]  WITH CHECK ADD  CONSTRAINT [FK_PersonReward_Person] FOREIGN KEY([PERSON_ID])
REFERENCES [dbo].[Person] ([ID])
GO

ALTER TABLE [dbo].[PersonReward] CHECK CONSTRAINT [FK_PersonReward_Person]
GO

ALTER TABLE [dbo].[PersonReward]  WITH CHECK ADD  CONSTRAINT [FK_PersonReward_Reward] FOREIGN KEY([REWARD_ID])
REFERENCES [dbo].[Reward] ([ID])
GO

ALTER TABLE [dbo].[PersonReward] CHECK CONSTRAINT [FK_PersonReward_Reward]
GO
